package com.jkl.controller.project;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.jkl.entity.project.dto.VillageDTO;
import com.jkl.entity.project.po.*;
import com.jkl.entity.project.vo.*;
import com.sun.xml.internal.rngom.parse.host.Base;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jkl.entity.BaseResponseDTO;
import com.jkl.entity.ListId;
import com.jkl.entity.bsAddition.BsAddition;
import com.jkl.entity.bsWorkflowLog.BsWorkflowLog;
import com.jkl.entity.dept.BSDept;
import com.jkl.entity.drTable.DrTable;
import com.jkl.entity.index.IndexCharts;
import com.jkl.entity.notice.PnNotice;
import com.jkl.entity.param.BSParam;
import com.jkl.entity.po.user.BSUser;
import com.jkl.entity.project.extend.PJVillage;
import com.jkl.entity.project.extend.ProjectSource;


import com.jkl.entity.role.BsRole;
import com.jkl.service.dept.inter.BSDeptServiceInterface;
import com.jkl.service.project.inter.IPJProjectService;
import com.jkl.service.user.inter.BSUserServiceInterface;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/jky/project")
@Slf4j
public class ProjectController {
	@Autowired
	private IPJProjectService projectService;
	
	@Autowired
	private BSUserServiceInterface userService;
	@Autowired
	private BSDeptServiceInterface bsDeptServiceInterface;

	/**
	 * @author xgs
	 * @return
	 * @description 通过ID来初始化对应的区县的车辆信息
	 * @time 2021/2/23 9:44
	 */  
	@PostMapping("/initCarDataById")
	public BaseResponseDTO initCarDataById(@RequestParam(value = "deptId") String deptId) {
		return projectService.initCarDataById(deptId);
	}
	/**
	 * @author xgs
	 * @return
	 * @description 初始化嘉兴车辆的信息
	 * @time 2021/2/22 16:09
	 */
	@PostMapping("/initCarData")
	public BaseResponseDTO initCarData() {
		return projectService.initCarData();
	}
	/**
	 * @author xgs
	 * @return
	 * @description 通过id初始化车辆的路线
	 * @time 2021/1/21 15:02
	 */
	@PostMapping("/queryCarTransportRoutes")
	public BaseResponseDTO queryCarTransportRoutes(@RequestParam(value = "vehicleId") String vehicleId) {
		return projectService.queryCarTransportRoutes(vehicleId);
	}

	/**
	 * @author xgs
	 * @return
	 * @description  保存车辆路线
	 * @time 2021/1/21 9:31
	 */
	@PostMapping("/saveCarTransportRoutes")
	public int saveCarTransportRoutes(@RequestBody PJProjectCarVO param){
		BaseResponseDTO returnDate = projectService.queryCarTransportRoutes(String.valueOf(param.getVehicleId()));
		JSONArray array = returnDate.getReturnData().getJSONArray("sourceList");
		List<PJProject> pjProjectList = JSONObject.parseArray(array.toJSONString(), PJProject.class);
		if(pjProjectList.size() != 0) {
			projectService.deleteCarTransportRoutes(String.valueOf(param.getVehicleId()));
		}
		return projectService.saveCarTransportRoutes(param);
	}

	// 首页start
	@PostMapping("/homePageLeft")
	public List<HomePageLeft> homePageLeft(@RequestParam(value = "homePageName") String homePageName) {
		return projectService.homePageLeft(homePageName);
	}
    
	@PostMapping("/homePageLine")
	public List<HomePageLeft> homePageLine(@RequestParam(value = "homePageName") String homePageName) {
		return projectService.homePageLine(homePageName);
	}
	// 首页end

	// 图表分析
	@PostMapping("/statisticsSiteType") // 查询列表
	public BaseResponseDTO statisticsSiteType(@RequestBody StatisticsSiteType param) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		List<StatisticsSiteType> projectList = projectService.statisticsSiteType(param);
		JSONObject returnJson = new JSONObject();
		returnJson.put("projectList", projectList);
		returnData.setReturnData(returnJson);
		return returnData;
	}

	// 垃圾站点start
	@PostMapping("/queryProjectByparamsNew") // 查询列表
	public BaseResponseDTO queryProjectByparamsNew(@RequestBody PJProject param) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		PageInfo<PJProject> projectList = projectService.queryProjectByparamsNew(param);
		JSONObject returnJson = new JSONObject();
		returnJson.put("projectList", projectList);
		returnData.setReturnData(returnJson);
		return returnData;
	}

	// 垃圾站点start
	@PostMapping("/queryProjectByparamsVillage") // 查询列表
	public BaseResponseDTO queryProjectByparamsVillage(@RequestBody PJVillage param) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		PageInfo<PJProject> projectList = projectService.queryProjectByparamsVillage(param);
		JSONObject returnJson = new JSONObject();
		returnJson.put("projectList", projectList);
		returnData.setReturnData(returnJson);
		return returnData;
	}

	// 垃圾站点全部信息
	@PostMapping("/queryProjectListByParam") // 查询列表
	public BaseResponseDTO queryProjectListByParam(@RequestBody PJProject param) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		List<PJProject> projectList = projectService.queryProjectListByParam(param);
		JSONObject returnJson = new JSONObject();
		returnJson.put("projectList", projectList);
		returnData.setReturnData(returnJson);
		return returnData;
	}

	// 更改状态
	@PostMapping("/updateStatus")
	public int updateStatus(@RequestParam(value = "rowId") String rowId,
			@RequestParam(value = "status") String Status) {
		return projectService.updateStatus(rowId, Status);
	}

	
	
	@PostMapping("/addBurn")
	public int addBurn(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectBurn param = JSON.parseObject(data, PJProjectBurn.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		return projectService.addBurn(param, fileList);
	}

	
	@PostMapping("/queryBurn") // 建筑垃圾-查询单个
	public PJProjectBurn queryBurn(@RequestParam(value = "projectId") String projectId) {
		return projectService.queryBurn(projectId);
	}

	
	@PostMapping("/updateBurn") // 建筑垃圾-更新
	public void updateBurn(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectBurn param = JSON.parseObject(data, PJProjectBurn.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		projectService.updateBurn(param, fileList);
	}



	@PostMapping("/addKitchen")
	public int addKitchen(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectKitchen param = JSON.parseObject(data, PJProjectKitchen.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());  
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		return projectService.addKitchen(param, fileList);
	}
	@PostMapping("/updateKitchen") // 建筑垃圾-更新
	public void updateKitchen(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectKitchen param = JSON.parseObject(data, PJProjectKitchen.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		projectService.updateKitchen(param, fileList);
	}
	@PostMapping("/queryKitchen") // 建筑垃圾-查询单个
	public PJProjectKitchen queryKitchen(@RequestParam(value = "projectId") String projectId) {
		return projectService.queryKitchen(projectId);
	}


	// 经纬度
	/*@PostMapping("/queryProjectBycoordinate") // 经纬度表查询列表
	public BaseResponseDTO queryProjectBycoordinate(@RequestBody PJProjectNew param) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		PageInfo<PJProjectNew> projectList = projectService.queryProjectByparamsNew(param);
		JSONObject returnJson = new JSONObject();
		returnJson.put("projectList", projectList);
		returnData.setReturnData(returnJson);
		return returnData;
	}*/

	@PostMapping("/queryCoordinate") // 经纬度-查询单个
	public PJProjectAddCoordinate queryCoordinate(@RequestParam(value = "projectId") String projectId) {
		return projectService.queryCoordinate(projectId);
	}

	@PostMapping("/updateCoordinate") // 建筑垃圾-更新
	public int updateCoordinate(@RequestBody PJProject param) {
		return projectService.updateCoordinate(param);
	}


	@PostMapping("/queryCoordinateAll") // 经纬度-查询列表
	public List<PJProjectNew> queryCoordinateAll(@RequestBody PJProjectNew param) {
		return projectService.queryCoordinateAll(param);
	}

	
	// 垃圾站点end

	// 垃圾车辆start
	@PostMapping("/queryCarProject") // 查询列表
	public BaseResponseDTO queryCarProject(@RequestBody PJProjectCar param) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		PageInfo<PJProjectCar> projectList = projectService.queryCarProject(param);
		JSONObject returnJson = new JSONObject();
		returnJson.put("projectList", projectList);
		returnData.setReturnData(returnJson);
		return returnData;
	}



	@PostMapping("/queryCarObject") // 建筑垃圾-查询单个
	public PJProjectCar queryCarObject(@RequestParam(value = "projectId") String projectId) {
		return projectService.queryCarObject(projectId);
	}

	@PostMapping("/addCarProject") // 添加
	public int addCarProject(@RequestBody PJProjectCar param) {
		return projectService.addCarProject(param);
	}

	@PostMapping("/addVillageProject") // 添加
	public int addVillageProject(@RequestBody PJProject param) {
		return projectService.addVillageProject(param);
	}


	@PostMapping("/updateCarProject") // 修改
	public int updateCarProject(@RequestBody PJProjectCar param) {
		return projectService.updateCarProject(param);
	}

	@PostMapping("/delCarProjectById")
	public Integer delCarProjectById(@RequestParam(value = "carId") String carId) {
		return projectService.delCarProjectById(carId);
	}
	// 垃圾车辆end

	// 绩效考核start
	@PostMapping("/queryIndexSetting") // 查询列表
	public BaseResponseDTO queryIndexSetting(@RequestBody PJProjectIndexSetting param) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		PageInfo<PJProjectIndexSetting> projectList = projectService.queryIndexSetting(param);
		JSONObject returnJson = new JSONObject();
		returnJson.put("projectList", projectList);
		returnData.setReturnData(returnJson);
		return returnData;
	}

	@PostMapping("/queryIndexSettingObject") // 根据ID查询单个
	public BaseResponseDTO queryIndexSettingObject(@RequestParam(value = "projectId") String projectId) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		PJProjectIndexSetting indexSettingObject = projectService.queryIndexSettingObject(projectId);
		JSONObject returnJson = new JSONObject();
		returnJson.put("indexSettingObject", indexSettingObject);
		returnData.setReturnData(returnJson);
		return returnData;
	}

	// 绩效考核end

	// 图表分析

	@PostMapping("/queryInit") // 加载初始化
	public BaseResponseDTO queryInit(@RequestParam(value = "groupCode") String groupCode) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		PageInfo<BSParam> projectList = projectService.queryInit(groupCode);
		JSONObject returnJson = new JSONObject();
		returnJson.put("projectList", projectList);
		returnData.setReturnData(returnJson);
		return returnData;
	}

	@GetMapping("/getProjectCode")
	public String getProjectCode(HttpServletRequest request, HttpServletResponse response,
			@RequestParam(value = "deptId") String deptId) {
		return projectService.getProjectCode(deptId);
	}

	/**
	 * 新增
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	/*2 @PostMapping("/addProject")
	public Object addProject(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProject projetInfo = JSON.parseObject(data, PJProject.class);
		List<MultipartFile> fileList = null;
		// 将当前上下文初始化给 CommonsMutipartResolver （多部分解析器）
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			// 将request变成多部分request
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		int projectId = projectService.addProject(projetInfo, fileList);
		return projectId;
	}*/

	/**
	 * 新增页面提交
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	/*@PostMapping("/submitProject")
	public BaseResponseDTO submitProject(HttpServletRequest request, HttpServletResponse response) {
		BaseResponseDTO dto = new BaseResponseDTO();
		String data = request.getParameter("form");
		PJProject projetInfo = JSON.parseObject(data, PJProject.class);
		List<MultipartFile> fileList = null;
		// 将当前上下文初始化给 CommonsMutipartResolver （多部分解析器）
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			// 将request变成多部分request
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		BSUser user = (BSUser) request.getSession().getAttribute("user");
		projetInfo.setPersonId(user.getPersonId());

		if (projetInfo.getRowId() == null) {
			projectService.addProject(projetInfo, fileList);
		} else {
			projectService.submitProject(projetInfo, fileList);
		}

		return dto;
	}
*/
	/**
	 * 市局审核
	 * 
	 * @param projectInfo
	 */
/*	@PostMapping("/ctiyAuditProject")
	public void ctiyAuditProject(HttpServletRequest request, HttpServletResponse response,
			@RequestBody PJProject projectInfo) {
		BSUser user = (BSUser) request.getSession().getAttribute("user");
		projectInfo.setPersonId(user.getPersonId());
		projectService.ctiyAuditProject(projectInfo);
	}*/

	/**
	 * 省局审核
	 * 
	 * @param projectInfo
	 */
	/*@PostMapping("/provinceAuditProject")
	public void provinceAuditProject(HttpServletRequest request, HttpServletResponse response,
			@RequestBody PJProject projectInfo) {
		BSUser user = (BSUser) request.getSession().getAttribute("user");
		projectInfo.setPersonId(user.getPersonId());
		projectService.provinceAuditProject(projectInfo);
	}*/

	@PostMapping("/projectReport")
	public BaseResponseDTO projectReport(HttpServletRequest request, HttpServletResponse response) {
		BaseResponseDTO dto = new BaseResponseDTO();
		String data = request.getParameter("form");
		ProjectReportVO projectReportVO = JSON.parseObject(data, ProjectReportVO.class);
		List<MultipartFile> fileList = null;
		// 将当前上下文初始化给 CommonsMutipartResolver （多部分解析器）
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			// 将request变成多部分request
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		BSUser user = (BSUser) request.getSession().getAttribute("user");
		projectReportVO.setPersonId(user.getPersonId());
		projectService.projectReport(projectReportVO, fileList);
		return dto;
	}

	/**
	 * 修改页面保存提交
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	/*@PostMapping("/updateProject")
	public BaseResponseDTO updateProject(HttpServletRequest request, HttpServletResponse response) {
		BaseResponseDTO returnDto = new BaseResponseDTO();
		String data = request.getParameter("form");
		PJProject projectInfo = JSON.parseObject(data, PJProject.class);
		String delePics = request.getParameter("deletePic");
		List<PJProjectPicture> delePicList = JSONObject.parseArray(delePics, PJProjectPicture.class);
		List<MultipartFile> fileList = null;
		// 将当前上下文初始化给 CommonsMutipartResolver （多部分解析器）
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			// 将request变成多部分request
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		BSUser user = (BSUser) request.getSession().getAttribute("user");
		projectInfo.setPersonId(user.getPersonId());
		projectService.updateProjectInf(projectInfo, delePicList, fileList);
		return returnDto;
	}*/

	/**
	 * 查询信息
	 * 
	 * @param projectId
	 * @return
	 */
	@GetMapping("/queryProjectInfoById")
	public BaseResponseDTO queryProjectInfoById(@RequestParam(value = "projectId") String projectId) {
		BaseResponseDTO returnDto = new BaseResponseDTO();
		JSONObject data = projectService.queryProjectInfoById(projectId);
		returnDto.setReturnData(data);
		return returnDto;

	}

	@GetMapping("/queryProjectLogByProjectId")
	public BaseResponseDTO queryProjectLogByProjectId(@RequestParam(value = "projectId") String projectId) {
		BaseResponseDTO returnDto = new BaseResponseDTO();
		JSONObject data = projectService.queryProjectLogByProjectId(projectId);
		returnDto.setReturnData(data);
		return returnDto;
	}

	@PostMapping("/queryProjectByparams")
	public BaseResponseDTO queryProjectByparams(@RequestBody PJProject param) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		PageInfo<PJProject> projectList = projectService.queryProjectByparams(param);
		JSONObject returnJson = new JSONObject();
		returnJson.put("projectList", projectList);
		returnData.setReturnData(returnJson);
		return returnData;
	}

	@DeleteMapping("/deleteById")
	public Boolean deleteById(@RequestBody PJProject pjProject) {
		return projectService.deleteById(pjProject);
	}

	@PostMapping("/getProjectEcharts")
	public List<ProjectEcharts> getProjectEcharts(@RequestBody ProjectEcharts projectEcharts) {
		return projectService.getProjectEcharts(projectEcharts);
	}

	/*1 @PostMapping("/getIndexCharts")
	public IndexCharts getIndexCharts(@RequestBody IndexCharts indexCharts) {
		return projectService.getIndexCharts(indexCharts);
	}*/
	
	@PostMapping("/putLog")
	public int putLog(@RequestBody SljptLog param) {
		return projectService.putLog(param);
	}
	
	@PostMapping("/getImport")
	public int getImport(@RequestBody List<DrTable> param) {
		return projectService.getImport(param);
	}
	
	@PostMapping("/insertTableLog")
	public int insertTableLog(@RequestBody List<DrTable> param) {
		return projectService.insertTableLog(param);
	}
	
	@PostMapping("/insertUpTableLog")
	public int insertUpTableLog(@RequestBody BsWorkflowLog param) {
		return projectService.insertUpTableLog(param);
	}
	
	
	@PostMapping("/indexImport")
	public int indexImport(@RequestBody List<XljptIndexImport> param) {
		return projectService.indexImport(param);
	}
	
	@PostMapping("/upImport")
	public Object upImport(@RequestBody List<Integer> param) {
		return projectService.upImport(param);
	}
	
	@PostMapping("/updateCode")
	public int updateCode(@RequestBody int param) {
		return projectService.updateCode(param);
	}
	

	@PostMapping("/addVillage")
	public int addVillage(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJVillage param = JSON.parseObject(data, PJVillage.class);
		List<MultipartFile> fileList1 = null;
		// List<MultipartFile> fileList2 = null;
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList1 = multiRequest.getFiles("files");
			// fileList2 = multiRequest.getFiles("files2");
		}
		return projectService.addVillage(param, fileList1);
	}

	@PostMapping("/addCar1")
	public int addCar1(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectCar param = JSON.parseObject(data, PJProjectCar.class);
		List<MultipartFile> fileList1 = null;
		// List<MultipartFile> fileList2 = null;
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList1 = multiRequest.getFiles("files");
			// fileList2 = multiRequest.getFiles("files2");
		}
		return projectService.addCar(param, fileList1);
	}
	@PostMapping("/queryVillage")
	public PJVillage queryVillage(int projectId) {
		return projectService.queryVillage(projectId);
	}


	@PostMapping("/getFile")
	public List<BsAddition> getFile(@RequestBody BsAddition param) {
		return projectService.getFile(param);
	}
	@PostMapping("/updateVillage")
	public int updateVillage(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJVillage param = JSON.parseObject(data, PJVillage.class);
		List<List<MultipartFile>> list = new ArrayList<List<MultipartFile>>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			list.add(multiRequest.getFiles("files"));
			//list.add(multiRequest.getFiles("files2"));
			//list.add(multiRequest.getFiles("files3"));
		}
		return projectService.updateVillage(param, list);
	}
	@PostMapping("/updateCar1")
	public int updateCar1(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectCar param = JSON.parseObject(data, PJProjectCar.class);
		List<List<MultipartFile>> list = new ArrayList<List<MultipartFile>>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			list.add(multiRequest.getFiles("files"));
			//list.add(multiRequest.getFiles("files2"));
			//list.add(multiRequest.getFiles("files3"));
		}
		return projectService.updateCar1(param, list);
	}
	@PostMapping("/delProject") // 建筑垃圾-查询单个
	public int delProject(@RequestParam(value = "projectId") String projectId) {
		return projectService.delProject(projectId);
	}
	@PostMapping("/delFile")
	public int delFile(@RequestBody BsAddition param) {
		return projectService.delFile(param);
	}
	@PostMapping("/queryProjectLogExtendList")
	public List<PJProjectLogExtend> queryProjectLogExtendList(@RequestParam(value = "projectId") String projectId,
			@RequestParam(value = "userType") String userType) {
		return projectService.queryProjectLogExtendList(projectId, userType);
	}
	@PostMapping("/getFatherProjectList")
	public List<PJProject> getFatherProjectList(@RequestParam(value = "deptId") int deptId,
			@RequestParam(value = "projectType") String projectType) {
		return projectService.getFatherProjectList(deptId, projectType);
	}
	@PostMapping("/getPjProjectUnitList")
	public List<PJProjectUnit> getPjProjectUnitList(@RequestParam(value = "projectId") String projectId) {
		return projectService.getPjProjectUnitList(projectId);
	}
	@PostMapping("/addWorkflowLog")
	public void addWorkflowLog(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		BsWorkflowLog bsWorkflowLog = JSON.parseObject(data, BsWorkflowLog.class);
		List<MultipartFile> fileList = null;
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			// 将request变成多部分request
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		projectService.addWorkflowLog(bsWorkflowLog, fileList);
	}
	@PostMapping("/projectLogExtendPass")   
	public int projectLogExtendPass(@RequestParam(value = "rowId") String rowId) {
		return projectService.projectLogExtendPass(rowId);
	}
	@PostMapping("/projectLogExtendFail")
	public int projectLogExtendFail(@RequestParam(value = "rowId") String rowId,
			@RequestParam(value = "workflowLogId") String workflowLogId,
			@RequestParam(value = "projectId") String projectId) {
		return projectService.projectLogExtendFail(rowId, workflowLogId, projectId);
	}

	@PostMapping("/getWorkflowLogObj")
	public BsWorkflowLog getWorkflowLogObj(@RequestParam(value = "rowId") int rowId) {
		return projectService.getWorkflowLogObj(rowId);
	}
	@PostMapping("/addCollect")
	public int addCollect(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectCollect param = JSON.parseObject(data, PJProjectCollect.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		return projectService.addCollect(param, fileList);
	}

	@PostMapping("/addTransport")
	public int addTransport(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectTransport param = JSON.parseObject(data, PJProjectTransport.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		return projectService.addTransport(param, fileList);
	}
	@PostMapping("/addLandfill")
	public int addLandfill(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectLandfill param = JSON.parseObject(data, PJProjectLandfill.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		return projectService.addLandfill(param, fileList);
	}
	@PostMapping("/addArchitecture") // 添加
	public int addArchitecture(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectBuild param = JSON.parseObject(data, PJProjectBuild.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		return projectService.addArchitecture(param, fileList);
	}
	@PostMapping("/queryCollect") // 建筑垃圾-查询单个
	public PJProjectCollect queryCollect(@RequestParam(value = "projectId") String projectId) {
		return projectService.queryCollect(projectId);
	}
	@PostMapping("/updateCollect") // 建筑垃圾-更新
	public void updateCollect(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectCollect param = JSON.parseObject(data, PJProjectCollect.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		projectService.updateCollect(param, fileList);
	}
	@PostMapping("/queryTransport") // 建筑垃圾-查询单个
	public PJProjectTransport queryTransport(@RequestParam(value = "projectId") String projectId) {
		return projectService.queryTransport(projectId);
	}
	@PostMapping("/updateTransport") // 建筑垃圾-更新
	public void updateTransport(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectTransport param = JSON.parseObject(data, PJProjectTransport.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		projectService.updateTransport(param, fileList);
	}

	@PostMapping("/queryLandfill") // 建筑垃圾-查询单个
	public PJProjectLandfill queryLandfill(@RequestParam(value = "projectId") String projectId) {
		return projectService.queryLandfill(projectId);
	}
	@PostMapping("/updateLandfill") // 建筑垃圾-更新
	public void updateLandfill(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectLandfill param = JSON.parseObject(data, PJProjectLandfill.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		projectService.updateLandfill(param, fileList);
	}

	@PostMapping("/queryArchitecture") // 建筑垃圾-查询单个
	public PJProjectBuild queryArchitecture(@RequestParam(value = "projectId") String projectId) {
		return projectService.queryArchitecture(projectId);
	}
	@PostMapping("/updateArchitecture") // 建筑垃圾-更新
	public void updateArchitecture(HttpServletRequest request, HttpServletResponse response) {
		String data = request.getParameter("form");
		PJProjectBuild param = JSON.parseObject(data, PJProjectBuild.class);
		List<MultipartFile> fileList = new ArrayList<>();
		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
				request.getSession().getServletContext());
		if (multipartResolver.isMultipart(request)) {
			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
			fileList = multiRequest.getFiles("files");
		}
		projectService.updateArchitecture(param, fileList);
	}
	@PostMapping("/getTree")
	public List<BSDept> getTree() {
		List<BSDept> depts = bsDeptServiceInterface.getTree(330000);
		return depts;
	}
	@PostMapping("/getPjProjectUnit")
	public List<Integer> getPjProjectUnit(@RequestParam(value = "rowId") int rowId) {
		return projectService.getPjProjectUnit(rowId);
	}
	@PostMapping("/relationCollect")
	public void relationCollect(@RequestBody BsRole params) {
		projectService.relationCollect(params);
	}
	@PostMapping("/getProjectLogExtendList")
	public PageInfo<PJProjectLogExtend> getProjectLogExtendList(@RequestBody PJProjectLogExtend params) {
		return projectService.getProjectLogExtendList(params);
	}
	@PostMapping("/setCarState")
	public void setCarState(@RequestBody String rowIds) {System.out.println(rowIds);
	   String[] counts= rowIds.split(":");String str=counts[1];
	   String[] str2=str.split(",");int length=str2.length;
	   str2[0]=str2[0].substring(1,10);str2[length-1]=str2[length-1].substring(0, 9);
	          for(int i=0;i<str2.length;i++) {
			  //System.out.println(Integer.parseInt(str2[i]));
			  projectService.setCarOne(Integer.parseInt(str2[i])) ;
		  }
		//JSONObject returnJson = new JSONObject();
		//returnJson.put("projectList", carList);
		//BaseResponseDTO returnData = new BaseResponseDTO();
		//returnData.setReturnData(returnJson);
		//return returnData;
	}
	@PostMapping("/queryAllCar")
	public BaseResponseDTO queryAllCar() {
		List<PJProjectCar> carList=projectService.queryAllCar();
		Iterator<PJProjectCar> iterator=carList.iterator();
		while(iterator.hasNext()) {
			projectService.setCarOne(iterator.next().getRowId()) ;	
		}
		JSONObject returnJson = new JSONObject();
		returnJson.put("projectList", carList);
		BaseResponseDTO returnData = new BaseResponseDTO();
		returnData.setReturnData(returnJson);
		return returnData;
	}
	@PostMapping("/queryProject")
	public BaseResponseDTO queryProject(@RequestBody ListId ld) {
		JSONObject returnJson = new JSONObject();
		List<PJProject> listProject=new ArrayList();
		List<PJProjectCollect> listCollect=new ArrayList();
		List<PJProjectTransport> listTransport=new ArrayList();  
		List<PJProjectBurn> listBurn=new ArrayList();
		List<PJProjectKitchen> listKitchen=new ArrayList();  
		List<PJProjectLandfill> listLandfill=new ArrayList();
		List<PJProjectBuild> listBuild=new ArrayList(); 
		List<BsAddition> listFile=new ArrayList(); 
		List<PJVillage> listVillage=new ArrayList(); 
		List<BsWorkflowLog> listWorkflowLog=new ArrayList(); 
		List<PJProjectLogExtend> listProjectLogExtend=new ArrayList(); 
		  
		int[] param=ld.getListId();
		for(int i=0;i<param.length;i++) {  
		 PJProject project=projectService.queryProjectById(param[i]); 
		  listProject.add(project); 
		  List<BsWorkflowLog> workflowLog=projectService.queryWorkflowLog(param[i]);
		  for(BsWorkflowLog wf:workflowLog) {
			  if(wf!=null) {
			  listWorkflowLog.add(wf);
			  }
		  }
		  if(ld.getSourceTable().equals("pj_project")) {
		  List <BsAddition> bsAddition=projectService.queryBsAddition(param[i]);
		  for(BsAddition bs:bsAddition) {
			if(bs!=null) {
			  listFile.add(bs);  
			  }
		    }
		  }
		  if(ld.getSourceTable().equals("bs_workflow_log")) {
			  for(BsWorkflowLog wg:listWorkflowLog) {
				  if(wg.getIsFile()!=null&&wg.getIsFile().equals("1")) {
				  BsAddition addition=projectService.queryBsAddition2(wg.getRowId()); 
				  if(addition!=null) {
				  listFile.add(addition);
				  }
				  PJProjectLogExtend proex=projectService.queryProjectLogExtend(wg.getRowId());
				  if(proex!=null) {
				  listProjectLogExtend.add(proex);
				   }
				 }
			  }
		  }
		  //System.out.println(project);
		  String projectType=project.getProjectType();
		  if(projectType.equals("101")) { 
		  PJProjectCollect projectCollect=projectService.queryCollectProject(param[i]);//
		  if(projectCollect!=null) {
		  listCollect.add(projectCollect);
		    }
		  } 
		  else if(projectType.equals("102")) { 
		  PJProjectTransport projectTransport=projectService.queryTransportProject(param[i]);
		  if(projectTransport!=null) {
		  listTransport.add(projectTransport);
		    }
		  } 
		  else if(projectType.equals("103")) {
		  PJProjectBurn projectBurn=projectService.queryBurnProject(param[i]);
		  if(projectBurn!=null) {
		  listBurn.add(projectBurn);
		    }
		  } 
		  else if(projectType.equals("104")) { 
		  PJProjectKitchen projectKitchen=projectService.queryKitchenProject(param[i]);
		  if(projectKitchen!=null) {
		  listKitchen.add(projectKitchen);
		    }
		  } 
		  else if(projectType.equals("105")) { 
		  PJProjectLandfill projectLandfill=projectService.queryLandfillProject(param[i]);
		  if(projectLandfill!=null) {
		  listLandfill.add(projectLandfill);
		    }
		  } 
		  else if(projectType.equals("2201")||projectType.equals("2301")||projectType.equals("2302")) { 
			  PJVillage village=projectService.queryVillage(param[i]);
			  if(village!=null) {
			  listVillage.add(village);
			  }
	      } 
		 
		  else if(projectType.equals("106")) { 
		  PJProjectBuild projectBuild=projectService.queryBuildProject(param[i]);
		  if(projectBuild!=null) {
		  listBuild.add(projectBuild);
		    }
		  } 
		  else {
			  
		  }
		}
		 
		returnJson.put("listProject", listProject);
		returnJson.put("listCollect", listCollect);
		returnJson.put("listTransport", listTransport);
		returnJson.put("listBurn", listBurn);
		returnJson.put("listKitchen", listKitchen);
		returnJson.put("listLandfill", listLandfill);
		returnJson.put("listBuild", listBuild);
		returnJson.put("listFile", listFile);
		returnJson.put("listVillage", listVillage);
		returnJson.put("listWorkflowLog", listWorkflowLog);
		returnJson.put("listProjectLogExtend", listProjectLogExtend);
		BaseResponseDTO returnData = new BaseResponseDTO();
		returnData.setReturnData(returnJson);
		return returnData;
	}
	@PostMapping("/updateState")
	public BaseResponseDTO updateState(@RequestBody ListId ld) {
		JSONObject returnJson = new JSONObject();
		int[] param=ld.getListId();
		for(int i=0;i<param.length;i++) { 
			PJProject project=projectService.queryProjectById(param[i]);
            if(ld.getIsProject()==1) {
            	projectService.setProjectStateTest(param[i]);	
			}
            else {
			projectService.setProjectState(param[i]); 
            }
			 projectService.setProjectState7(param[i]); 
			String projectType=project.getProjectType();
			 if(projectType.equals("101")) { 
				 projectService.setProjectState1(param[i]);  
			 }
			 else if(projectType.equals("102")) {
				 projectService.setProjectState2(param[i]);  
			 }
			 else if(projectType.equals("103")) {
				 projectService.setProjectState3(param[i]);  
			 }
			 else if(projectType.equals("104")) {
				 projectService.setProjectState4(param[i]);  
			 }
			 else if(projectType.equals("105")) {
				 projectService.setProjectState5(param[i]);  
			 }
			 else if(projectType.equals("2201")||projectType.equals("2301")||projectType.equals("2302")) {
				 projectService.setVillageState(param[i]);
				 projectService.setWorkflowLogState(param[i]);
			 }
			 else {
				 projectService.setProjectState6(param[i]); 
				
			 }
		}
		BaseResponseDTO returnData = new BaseResponseDTO();
		returnData.setReturnData(returnJson);
		return returnData;
	}
	@PostMapping("queryAllProject")
	public BaseResponseDTO queryAllProject(@RequestBody String type){
	    List<Integer> ids=new ArrayList<Integer>();
	    List<PJProject> listProject=new ArrayList<PJProject>();
	    List<PJProjectCollect> listCollect=new ArrayList<PJProjectCollect>();
		List<PJProjectTransport> listTransport=new ArrayList<PJProjectTransport>();
		List<PJProjectBurn> listBurn=new ArrayList<PJProjectBurn>();
		List<PJProjectKitchen> listKitchen=new ArrayList<PJProjectKitchen>();
		List<PJProjectLandfill> listLandfill=new ArrayList<PJProjectLandfill>();
		List<PJProjectBuild> listBuild=new ArrayList<PJProjectBuild>();
		List<BsAddition> listFile=new ArrayList(); 
		List<BsWorkflowLog> listWorkflowLog=new ArrayList<BsWorkflowLog>();
		List<PJVillage> listVillage=new ArrayList<PJVillage>();
		List<PJProjectLogExtend> listProjectLogExtend=new ArrayList(); 
		JSONObject returnJson = new JSONObject();
		if(type.equals("1")){
		  listProject=projectService.queryAllProject1();
		  listCollect=projectService.queryAllCollect();
		  listTransport=projectService.queryAllTransport(); 
		  listBurn=projectService.queryAllBurn();
		  listKitchen=projectService.queryAllKitchen(); 
		  listLandfill=projectService.queryAllLandfill();
		  listBuild=projectService.queryAllBuild(); 
		  returnJson.put("listCollect", listCollect);
		  returnJson.put("listTransport", listTransport);
		  returnJson.put("listBurn", listBurn);
		  returnJson.put("listKitchen", listKitchen);
		  returnJson.put("listLandfill", listLandfill);
		  returnJson.put("listBuild", listBuild);
		  returnJson.put("listVillage", listVillage);
		  returnJson.put("listWorkflowLog", listWorkflowLog);
		  returnJson.put("listProjectLogExtend", listProjectLogExtend);
		  for(PJProject pro:listProject) {
				ids.add(pro.getRowId());
			   }
		    listFile=projectService.queryAllBsAddition(ids); 
			returnJson.put("listProject", listProject);
			returnJson.put("listFile", listFile);
	     }
		
		else if(type.startsWith("2")) {
		  if(type.equals("22")) {
		    listProject=projectService.queryAllProject2();
		    }
		  else {
		    listProject=projectService.queryAllProject3();
		   }
		  List<Integer> id=new ArrayList<Integer>();
		  for(PJProject project:listProject) {
			id.add(project.getRowId());
		     }
		  for(int j=0;j<id.size();j++) {
		  PJVillage village=projectService.queryVillage(id.get(j));
		  listVillage.add(village);
		     }
		  listWorkflowLog=projectService.queryAllWorkflowLog(id);
		  returnJson.put("listCollect", listCollect);
		  returnJson.put("listTransport", listTransport);
		  returnJson.put("listBurn", listBurn);
		  returnJson.put("listKitchen", listKitchen);
		  returnJson.put("listLandfill", listLandfill);
		  returnJson.put("listBuild", listBuild);
		  returnJson.put("listVillage", listVillage);
		  returnJson.put("listWorkflowLog", listWorkflowLog);
		  returnJson.put("listProjectLogExtend", listProjectLogExtend);
		  for(PJProject pro:listProject) {
				ids.add(pro.getRowId());
			   }
		    listFile=projectService.queryAllBsAddition(ids); 
			returnJson.put("listProject", listProject);
			returnJson.put("listFile", listFile);
	     }
		
		else if(type.equals("4")) {
			listProject=projectService.queryAllProject4();
			List<Integer> list=new ArrayList<Integer>();
			for(PJProject project:listProject) {
			  list.add(project.getRowId());
			  if(project.getProjectType()!=null&&project.getProjectType().equals("103")) {
				  if(projectService.queryBurnProject(project.getRowId())!=null) {
				  listBurn.add(projectService.queryBurnProject(project.getRowId()));
				  }
			  }
			  else {
				  if(projectService.queryKitchenProject(project.getRowId())!=null) {
				  listKitchen.add(projectService.queryKitchenProject(project.getRowId())) ;
				  }
			  }
			 }
			listWorkflowLog=projectService.queryAllWorkflowLog(list);
			for(BsWorkflowLog wg:listWorkflowLog) {
				  if(wg.getIsFile()!=null&&wg.getIsFile().equals("1")) {
				  BsAddition addition=projectService.queryBsAddition2(wg.getRowId()); 
				  if(addition!=null) {
				  listFile.add(addition);
				  }
				  PJProjectLogExtend proex=projectService.queryProjectLogExtend(wg.getRowId());
				  if(proex!=null) {
				  listProjectLogExtend.add(proex);
				   }
				 }
			  }
			  returnJson.put("listCollect", listCollect);
			  returnJson.put("listTransport", listTransport);
			  returnJson.put("listBurn", listBurn);
			  returnJson.put("listKitchen", listKitchen);
			  returnJson.put("listLandfill", listLandfill);
			  returnJson.put("listBuild", listBuild);
			  returnJson.put("listVillage", listVillage);
			  returnJson.put("listWorkflowLog", listWorkflowLog);
			  returnJson.put("listProjectLogExtend", listProjectLogExtend);
			  returnJson.put("listProject", listProject);
			  returnJson.put("listFile", listFile);
			}
		else {
			
		}
		BaseResponseDTO returnData = new BaseResponseDTO();
		returnData.setReturnData(returnJson);
		return returnData;
		
	}
	@PostMapping("/setState")
	public BaseResponseDTO setState(@RequestBody int param) {
		JSONObject returnJson = new JSONObject();
		PJProject project=projectService.queryProjectByParam(param);
		projectService.setState(param); 
		 //projectService.setState7(param); 
		String projectType=project.getProjectType();System.out.print(projectType);
		 if(projectType.equals("101")) { 
			 projectService.setState1(param);  
		 }
		 else if(projectType.equals("102")) {
			 projectService.setState2(param);  
		 }
		 else if(projectType.equals("103")) {
			 projectService.setState3(param);  
		 }
		 else if(projectType.equals("104")) {
			 projectService.setState4(param);  
		 }
		 else if(projectType.equals("105")) {
			 projectService.setState5(param);  
		 }
		 else {
			 projectService.setState6(param); 
			
		 }
		 BaseResponseDTO returnData = new BaseResponseDTO();
			returnData.setReturnData(returnJson);
			return returnData;
	}
	@PostMapping("/setBsAdditionState")
	public BaseResponseDTO setBsAdditionState(@RequestBody int param) {
		JSONObject returnJson = new JSONObject();
		 projectService.setBsAdditionState(param);
		 BaseResponseDTO returnData = new BaseResponseDTO();
			returnData.setReturnData(returnJson);
			return returnData;
	}
	
	@PostMapping("/setProjectState")
	public BaseResponseDTO setProjectState(@RequestBody ProjectSource param) {
		BsWorkflowLog[] workflowLogList=param.getWorkflowLogList();
		PJProject[] projectList=param.getProjectList();
		PJProjectLogExtend[] projectLogExtendList=param.getProjectLogExtendList();
		//PJProjectBurn[] burnList=param.getBurnList();
		//PJProjectKitchen[] kitchenList=param.getKitchenList();
		if(projectList!=null&&projectList.length!=0) {
			for(PJProject project:projectList) {
				projectService.updateProject(project);
			}
		}
		if(workflowLogList!=null&&workflowLogList.length!=0) {
			for(BsWorkflowLog workflowLog:workflowLogList) {
				BsWorkflowLog wf=projectService.getWorkflowLog(workflowLog.getRowId());
				if(wf==null) {
					projectService.	insertWorkflowLogObj(workflowLog);
				}
				else {
					projectService.updateWorkflowLog2(workflowLog);
				}
			  }
			}
	   if(projectLogExtendList!=null&&projectLogExtendList.length!=0) {
			for(PJProjectLogExtend pexd:projectLogExtendList) {
				projectService.updateProjectLogExtend(pexd);
			}
		}
		BaseResponseDTO returnData = new BaseResponseDTO();
		return returnData;
		}
	@PostMapping("/updateProjectState")
	public BaseResponseDTO updateProjectState(@RequestBody int rowId) {
		projectService.updateProjectState(rowId);
		BaseResponseDTO returnData = new BaseResponseDTO();
		return returnData;
	}
	@PostMapping("/setTestState")
	public void setTestState(@RequestBody int param) {
		projectService.setTestState(param);
	}



	// 附表四
	@PostMapping("/queryTableFour") // 查询列表
	public List<PJTableFour> queryTableFour(@RequestBody PJTableFour param) {
		return projectService.queryTableFour(param);
	}

	// 表二
	@PostMapping("/queryTableTwo") // 查询列表
	public List<PJTableTwo> queryTableTwo(@RequestBody PJTableTwo param) {
		return projectService.queryTableTwo(param);
	}

	/**
	 * @author: HXH
	 * @Description: 获取表五的报表数据
	 * @param params
	 * @return
	 */
	@PostMapping("/getTableFive")
	public List<DSVolumeTotal> getTableFive(@RequestBody DSVolumeTotal params) {
		return projectService.getTableFive(params);
	}

	/**
	 * @author: HXH
	 * @Description: 获取表六的报表数据
	 * @param params
	 * @return
	 */
	@PostMapping("/getTableSix")
	public List<businessWeightMonth> getTableSix(@RequestBody businessWeightMonth params) {
		return projectService.getTableSix(params);
	}
	@PostMapping("/getTableSixTotal")
	public List<businessWeightMonth> getTableSixTotal(@RequestBody businessWeightMonth params) {
		return projectService.getTableSixTotal(params);
	}

	/**
	 * @author: HXH
	 * @Description: 获取表三的报表数据
	 * @param params
	 * @return
	 */
	@PostMapping("/getTableThree")
	public List<DSVolumeScope> getTableThree(@RequestBody DSVolumeScope params) {
		return projectService.getTableThree(params);
	}

	@PostMapping("/addProject")
	public Integer addProject(@RequestBody ProjectVO projectVO){
		Integer flag = projectService.addProject(projectVO);
		return flag;
	}

	@PostMapping("/queryProject1")
	public VillageDTO queryProject1(int projectId) {
		return projectService.queryVillage1(projectId);
	}

	@PostMapping("/updateProject")
	public Integer updateProject(@RequestBody ProjectVO projectVO) {
		return projectService.updateProject1(projectVO);
	}
}
